#pragma once
#include "Runtime/BattleFirePrefix.h"
#include "Runtime/CGI/CGIPrefix.h"
#include "Runtime/Rendering/RenderResource.h"

namespace Alice{
    enum class EVertexStreamUsage : uint8
    {
        Default = 0 << 0,
        Instancing = 1 << 0,
        Overridden = 1 << 1,
        ManualFetch = 1 << 2
    };
    class VertexAttributes{
    public:
        uint8* mTexcoordData;
        uint8* mTangentData;
    };
    class CGIBuffer;
    class VertexInputStream
    {
    public:
        uint32 mStreamIndex;
        uint32 mOffset;
        uint32 mbIsStreamSourceSlot;
        union 
        {
            CGIBuffer*mVertexBuffer;
            void* mPointer;
        };
        VertexInputStream(){}
        VertexInputStream(uint32 inStreamIndex,uint32 inOffset,CGIBuffer*inVertexBuffer);
    };
    /**
     * A typed data source for a vertex factory which streams data from a vertex buffer.
     */
    struct FVertexStreamComponent
    {
        /** The vertex buffer to stream data from.  If null, no data can be read from this stream. */
        const VertexBuffer* mVertexBuffer = nullptr;

        /** The offset to the start of the vertex buffer fetch. */
        uint32 mStreamOffset = 0;

        /** The offset of the data, relative to the beginning of each element in the vertex buffer. */
        uint8 mOffset = 0;

        /** The stride of the data. */
        uint8 mStride = 0;
        
        /** The type of the data read from this stream. */
        EVertexElementType mType = VET_None;
        
	    EVertexStreamUsage mVertexStreamUsage = EVertexStreamUsage::Default;
        /**
         * Initializes the data stream to null.
         */
        FVertexStreamComponent()
        {}
        /**
         * Minimal initialization constructor.
         */
        FVertexStreamComponent(const VertexBuffer* InVertexBuffer, uint32 InOffset, uint32 InStride, EVertexElementType InType, EVertexStreamUsage Usage = EVertexStreamUsage::Default) :
            mVertexBuffer(InVertexBuffer),
            mStreamOffset(0),
            mOffset((uint8)InOffset),
            mStride((uint8)InStride),
            mType(InType),
            mVertexStreamUsage(Usage)
        {
            check(InStride <= 0xFF);
            check(InOffset <= 0xFF);
        }
    };
    struct FStaticMeshDataType
    {
        /** The stream to read the vertex position from. */
        FVertexStreamComponent PositionComponent;
    };
    
}
